package com.student.cqlg.dao;

import com.student.cqlg.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface UserDao {
    @Insert("insert into account_user (create_date, email, user_name, password, user_image) " +
            "value(#{createDate}, #{email}, #{userName}, #{password}, #{userImage})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void insertUser(User user);

    @Select("select * from account_user where user_name = #{userName} limit 1")
    User getUserByUserName(String userName);

    @Select("select * from account_user where user_name = #{userName} " +
            "and password = #{password} limit 1")
    User getUserByUserNameAndPassword(@Param("userName") String userName,
                                      @Param("password") String password);


}
